using System;
using UnityEngine;

/// <summary>
/// 零件信息
/// </summary>
[Serializable]
public class PartInfo
{
    public int partId;
    public string modelName;
    public UVector posFrom = new UVector(0, 0, 0);
    public UVector posTo = new UVector(0, 0, 0);
    public UVector rotFrom = new UVector(0, 0, 0);
    public UVector rotTo = new UVector(0, 0, 0);
    public Mode mode;
    public float lerpTime;

    public void SetPosFrom(Vector3 pos)
    {
        posFrom = new UVector(pos.x, pos.y, pos.z);
    }
    public void SetPosTo(Vector3 pos)
    {
        posTo = new UVector(pos.x, pos.y, pos.z);
    }
    public void SetRotFrom(Vector3 rot)
    {
        rotFrom = new UVector(rot.x, rot.y, rot.z);
    }
    public void SetRotTo(Vector3 rot)
    {
        rotTo = new UVector(rot.x, rot.y, rot.z);
    }

    public Vector3 GetPosFrom()
    {
        return new Vector3(posFrom.x, posFrom.y);
    }
    public Vector3 GetPosTo()
    {
        return new Vector3(posTo.x, posTo.y, posTo.z);
    }
    public Vector3 GetRotFrom()
    {
        return new Vector3(rotFrom.x, rotFrom.y, rotFrom.z);
    }
    public Vector3 GetRotTo()
    {
        return new Vector3(rotTo.x, rotTo.y, rotTo.z);
    }
}

[Serializable]
public class UVector
{
    public float x;
    public float y;
    public float z;

    public UVector(float x, float y, float z)
    {
        this.x = x;
        this.y = y;
        this.z = z;
    }

    public override string ToString()
    {
        return string.Format("x:{0} y: {1} z: {2}", x, y, z);
    }
}

/// <summary>
/// 动画模式
/// </summary>
public enum Mode
{
    /// <summary>
    /// 添加到最后一个
    /// </summary>
    Append,
    /// <summary>
    /// 和上一个同时执行
    /// </summary>
    Join
}